﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<string>" %>

<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Twitter - Are You Following Me Too?
</asp:Content>
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
<input id="username" type="hidden" value="<%= Request.Cookies["auth_name"].Value %>" />
<p style="font-size:1em;">Logged in as <%= Request.Cookies["auth_name"].Value %> <a href="/login/signout">Sign Out</a></p>
    <br />
    <div align="center">
    <div style="float:left; width:50%">
    <div>List of People Who Aren't Following Me</div>
    <div>
    <table id="results1"><tr><td></td></tr>
    </table>
    <div id='loading1' style="display: none;">This may take awhile. <img src='/Content/loading.gif' /></div>
    </div>
    <div align="center">
        <button id="startButton1" onclick="javascript:getList1(false);return false;">Get List</button>
        <button id="moreButton1" onclick="javascript:getList1(true);return false;" style="display: none;">More</button>
    </div>
    </div>
    <div style="float:left">
    <div>List of People Who I'm Not Following</div>
    <div>
    <table id="results2"><tr><td></td></tr>
    </table>
    <div id='loading2' style="display: none;">This may take awhile. <img src='/Content/loading.gif' /></div>
    </div>
    <div align="center">
        <button id="startButton2" onclick="javascript:getList2(false);return false;">Get List</button>
        <button id="moreButton2" onclick="javascript:getList2(true);return false;" style="display: none;">More</button>
    </div>
    </div>
    </div>

    <script type="text/javascript">
        function getList1(more) {
            $('#loading1').show();
            $('#startButton1,#moreButton1').hide();
            var name = $('#username').val();
            if(!more)
            {
                $.getJSON("/home/getlist1/" + name, null, resultCallback1);
            }
            else
            {
                $.getJSON("/home/morelist1/" + name, null, resultCallback1);
            }
        }
        function resultCallback1(data){
            $('#loading1').hide();
            var list = data[0];
            for (i = 0; i < list.length; i++) {
                $('#results1 tr:last').after("<tr><td>" + list[i] + "</td></tr>");
            }
            if(!data[1])
            {
                $('#moreButton1').show();
            }
        }
        
        function getList2(more) {
            $('#loading2').show();
            $('#startButton2,#moreButton2').hide();
            var name = $('#username').val();
            if(!more)
            {
                $.getJSON("/home/getlist2/" + name, null, resultCallback2);
            }
            else
            {
                $.getJSON("/home/morelist2/" + name, null, resultCallback2);
            }
        }
        function resultCallback2(data){
            $('#loading2').hide();
            var list = data[0];
            for (i = 0; i < list.length; i++) {
                $('#results2 tr:last').after("<tr><td>" + list[i] + "</td></tr>");
            }
            if(!data[1])
            {
                $('#moreButton2').show();
            }
        }
        
    </script>

</asp:Content>
